2000W / 48V LLC Battery-Charger  V1.00
cmsis_gcc.h
Go to the documentation of this file.
1 /**************************************************************************/
7 /*
8  * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
9  *
10  * SPDX-License-Identifier: Apache-2.0
11  *
12  * Licensed under the Apache License, Version 2.0 (the License); you may
13  * not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  * www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */
24 
25 #ifndef __CMSIS_GCC_H
26 #define __CMSIS_GCC_H
27 
28 /* ignore some GCC warnings */
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wsign-conversion"
31 #pragma GCC diagnostic ignored "-Wconversion"
32 #pragma GCC diagnostic ignored "-Wunused-parameter"
33 
34 /* Fallback for __has_builtin */
35 #ifndef __has_builtin
36  #define __has_builtin(x) (0)
37 #endif
38 
39 /* CMSIS compiler specific defines */
40 #ifndef __ASM
41  #define __ASM __asm
42 #endif
43 #ifndef __INLINE
44  #define __INLINE inline
45 #endif
46 #ifndef __STATIC_INLINE
47  #define __STATIC_INLINE static inline
48 #endif
49 #ifndef __STATIC_FORCEINLINE
50  #define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline
51 #endif
52 #ifndef __NO_RETURN
53  #define __NO_RETURN __attribute__((__noreturn__))
54 #endif
55 #ifndef __USED
56  #define __USED __attribute__((used))
57 #endif
58 #ifndef __WEAK
59  #define __WEAK __attribute__((weak))
60 #endif
61 #ifndef __PACKED
62  #define __PACKED __attribute__((packed, aligned(1)))
63 #endif
64 #ifndef __PACKED_STRUCT
65  #define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
66 #endif
67 #ifndef __PACKED_UNION
68  #define __PACKED_UNION union __attribute__((packed, aligned(1)))
69 #endif
70 #ifndef __UNALIGNED_UINT32 /* deprecated */
71  #pragma GCC diagnostic push
72  #pragma GCC diagnostic ignored "-Wpacked"
73  #pragma GCC diagnostic ignored "-Wattributes"
74  struct __attribute__((packed)) T_UINT32 { uint32_t v; };
75  #pragma GCC diagnostic pop
76  #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
77 #endif
78 #ifndef __UNALIGNED_UINT16_WRITE
79  #pragma GCC diagnostic push
80  #pragma GCC diagnostic ignored "-Wpacked"
81  #pragma GCC diagnostic ignored "-Wattributes"
83  #pragma GCC diagnostic pop
84  #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
85 #endif
86 #ifndef __UNALIGNED_UINT16_READ
87  #pragma GCC diagnostic push
88  #pragma GCC diagnostic ignored "-Wpacked"
89  #pragma GCC diagnostic ignored "-Wattributes"
90  __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
91  #pragma GCC diagnostic pop
92  #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
93 #endif
94 #ifndef __UNALIGNED_UINT32_WRITE
95  #pragma GCC diagnostic push
96  #pragma GCC diagnostic ignored "-Wpacked"
97  #pragma GCC diagnostic ignored "-Wattributes"
99  #pragma GCC diagnostic pop
100  #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
101 #endif
102 #ifndef __UNALIGNED_UINT32_READ
103  #pragma GCC diagnostic push
104  #pragma GCC diagnostic ignored "-Wpacked"
105  #pragma GCC diagnostic ignored "-Wattributes"
107  #pragma GCC diagnostic pop
108  #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
109 #endif
110 #ifndef __ALIGNED
111  #define __ALIGNED(x) __attribute__((aligned(x)))
112 #endif
113 #ifndef __RESTRICT
114  #define __RESTRICT __restrict
115 #endif
116 
117 
118 /* ########################### Core Function Access ########################### */
130 {
131  __ASM volatile ("cpsie i" : : : "memory");
132 }
133 
134 
141 {
142  __ASM volatile ("cpsid i" : : : "memory");
143 }
144 
145 
152 {
153  uint32_t result;
154 
155  __ASM volatile ("MRS %0, control" : "=r" (result) );
156  return(result);
157 }
158 
159 
160 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
161 
166 __STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void)
167 {
168  uint32_t result;
169 
170  __ASM volatile ("MRS %0, control_ns" : "=r" (result) );
171  return(result);
172 }
173 #endif
174 
175 
181 __STATIC_FORCEINLINE void __set_CONTROL(uint32_t control)
182 {
183  __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
184 }
185 
186 
187 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
188 
193 __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control)
194 {
195  __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory");
196 }
197 #endif
198 
199 
206 {
207  uint32_t result;
208 
209  __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
210  return(result);
211 }
212 
213 
220 {
221  uint32_t result;
222 
223  __ASM volatile ("MRS %0, apsr" : "=r" (result) );
224  return(result);
225 }
226 
227 
234 {
235  uint32_t result;
236 
237  __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
238  return(result);
239 }
240 
241 
248 {
249  register uint32_t result;
250 
251  __ASM volatile ("MRS %0, psp" : "=r" (result) );
252  return(result);
253 }
254 
255 
256 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
257 
262 __STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void)
263 {
264  register uint32_t result;
265 
266  __ASM volatile ("MRS %0, psp_ns" : "=r" (result) );
267  return(result);
268 }
269 #endif
270 
271 
277 __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)
278 {
279  __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
280 }
281 
282 
283 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
284 
289 __STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack)
290 {
291  __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : );
292 }
293 #endif
294 
295 
302 {
303  register uint32_t result;
304 
305  __ASM volatile ("MRS %0, msp" : "=r" (result) );
306  return(result);
307 }
308 
309 
310 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
311 
316 __STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void)
317 {
318  register uint32_t result;
319 
320  __ASM volatile ("MRS %0, msp_ns" : "=r" (result) );
321  return(result);
322 }
323 #endif
324 
325 
331 __STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack)
332 {
333  __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
334 }
335 
336 
337 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
338 
343 __STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
344 {
345  __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : );
346 }
347 #endif
348 
349 
350 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
351 
356 __STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void)
357 {
358  register uint32_t result;
359 
360  __ASM volatile ("MRS %0, sp_ns" : "=r" (result) );
361  return(result);
362 }
363 
364 
370 __STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack)
371 {
372  __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : );
373 }
374 #endif
375 
376 
383 {
384  uint32_t result;
385 
386  __ASM volatile ("MRS %0, primask" : "=r" (result) :: "memory");
387  return(result);
388 }
389 
390 
391 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
392 
397 __STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void)
398 {
399  uint32_t result;
400 
401  __ASM volatile ("MRS %0, primask_ns" : "=r" (result) :: "memory");
402  return(result);
403 }
404 #endif
405 
406 
412 __STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask)
413 {
414  __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
415 }
416 
417 
418 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
419 
424 __STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask)
425 {
426  __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory");
427 }
428 #endif
429 
430 
431 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
432  (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
433  (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
434 
439 __STATIC_FORCEINLINE void __enable_fault_irq(void)
440 {
441  __ASM volatile ("cpsie f" : : : "memory");
442 }
443 
444 
450 __STATIC_FORCEINLINE void __disable_fault_irq(void)
451 {
452  __ASM volatile ("cpsid f" : : : "memory");
453 }
454 
455 
461 __STATIC_FORCEINLINE uint32_t __get_BASEPRI(void)
462 {
463  uint32_t result;
464 
465  __ASM volatile ("MRS %0, basepri" : "=r" (result) );
466  return(result);
467 }
468 
469 
470 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
471 
476 __STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void)
477 {
478  uint32_t result;
479 
480  __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) );
481  return(result);
482 }
483 #endif
484 
485 
491 __STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri)
492 {
493  __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
494 }
495 
496 
497 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
498 
503 __STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri)
504 {
505  __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory");
506 }
507 #endif
508 
509 
516 __STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri)
517 {
518  __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
519 }
520 
521 
527 __STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void)
528 {
529  uint32_t result;
530 
531  __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
532  return(result);
533 }
534 
535 
536 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
537 
542 __STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void)
543 {
544  uint32_t result;
545 
546  __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) );
547  return(result);
548 }
549 #endif
550 
551 
557 __STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask)
558 {
559  __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
560 }
561 
562 
563 #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3))
564 
569 __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
570 {
571  __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory");
572 }
573 #endif
574 
575 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
576  (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
577  (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
578 
579 
580 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
581  (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
582 
588 __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void)
589 {
590  register uint32_t result;
591 
592  __ASM volatile ("MRS %0, psplim" : "=r" (result) );
593  return(result);
594 }
595 
596 
597 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
598  (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
599 
604 __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
605 {
606  register uint32_t result;
607 
608  __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) );
609  return(result);
610 }
611 #endif
612 
613 
619 __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
620 {
621  __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit));
622 }
623 
624 
625 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
626  (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
627 
632 __STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
633 {
634  __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit));
635 }
636 #endif
637 
638 
644 __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void)
645 {
646  register uint32_t result;
647 
648  __ASM volatile ("MRS %0, msplim" : "=r" (result) );
649 
650  return(result);
651 }
652 
653 
654 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
655  (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
656 
661 __STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void)
662 {
663  register uint32_t result;
664 
665  __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) );
666  return(result);
667 }
668 #endif
669 
670 
676 __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
677 {
678  __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit));
679 }
680 
681 
682 #if ((defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) && \
683  (defined (__ARM_ARCH_8M_MAIN__) && (__ARM_ARCH_8M_MAIN__ == 1)) )
684 
689 __STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
690 {
691  __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
692 }
693 #endif
694 
695 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
696  (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
697 
698 
699 #if ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
700  (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
701 
707 __STATIC_FORCEINLINE uint32_t __get_FPSCR(void)
708 {
709 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
710  (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
711 #if __has_builtin(__builtin_arm_get_fpscr) || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2)
712  /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */
713  return __builtin_arm_get_fpscr();
714 #else
715  uint32_t result;
716 
717  __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
718  return(result);
719 #endif
720 #else
721  return(0U);
722 #endif
723 }
724 
725 
731 __STATIC_FORCEINLINE void __set_FPSCR(uint32_t fpscr)
732 {
733 #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
734  (defined (__FPU_USED ) && (__FPU_USED == 1U)) )
735 #if __has_builtin(__builtin_arm_set_fpscr) || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2)
736  /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */
737  __builtin_arm_set_fpscr(fpscr);
738 #else
739  __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc", "memory");
740 #endif
741 #else
742  (void)fpscr;
743 #endif
744 }
745 
746 #endif /* ((defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
747  (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
748 
749 
750 
754 /* ########################## Core Instruction Access ######################### */
760 /* Define macros for porting to both thumb1 and thumb2.
761  * For thumb1, use low register (r0-r7), specified by constraint "l"
762  * Otherwise, use general registers, specified by constraint "r" */
763 #if defined (__thumb__) && !defined (__thumb2__)
764 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
765 #define __CMSIS_GCC_RW_REG(r) "+l" (r)
766 #define __CMSIS_GCC_USE_REG(r) "l" (r)
767 #else
768 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
769 #define __CMSIS_GCC_RW_REG(r) "+r" (r)
770 #define __CMSIS_GCC_USE_REG(r) "r" (r)
771 #endif
772 
777 #define __NOP() __ASM volatile ("nop")
778 
783 #define __WFI() __ASM volatile ("wfi")
784 
785 
791 #define __WFE() __ASM volatile ("wfe")
792 
793 
798 #define __SEV() __ASM volatile ("sev")
799 
800 
808 {
809  __ASM volatile ("isb 0xF":::"memory");
810 }
811 
812 
819 {
820  __ASM volatile ("dsb 0xF":::"memory");
821 }
822 
823 
830 {
831  __ASM volatile ("dmb 0xF":::"memory");
832 }
833 
834 
841 __STATIC_FORCEINLINE uint32_t __REV(uint32_t value)
842 {
843 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
844  return __builtin_bswap32(value);
845 #else
846  uint32_t result;
847 
848  __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
849  return result;
850 #endif
851 }
852 
853 
860 __STATIC_FORCEINLINE uint32_t __REV16(uint32_t value)
861 {
862  uint32_t result;
863 
864  __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
865  return result;
866 }
867 
868 
875 __STATIC_FORCEINLINE int16_t __REVSH(int16_t value)
876 {
877 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
878  return (int16_t)__builtin_bswap16(value);
879 #else
880  int16_t result;
881 
882  __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
883  return result;
884 #endif
885 }
886 
887 
895 __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
896 {
897  op2 %= 32U;
898  if (op2 == 0U)
899  {
900  return op1;
901  }
902  return (op1 >> op2) | (op1 << (32U - op2));
903 }
904 
905 
913 #define __BKPT(value) __ASM volatile ("bkpt "#value)
914 
915 
922 __STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value)
923 {
924  uint32_t result;
925 
926 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
927  (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
928  (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
929  __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
930 #else
931  uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */
932 
933  result = value; /* r will be reversed bits of v; first get LSB of v */
934  for (value >>= 1U; value != 0U; value >>= 1U)
935  {
936  result <<= 1U;
937  result |= value & 1U;
938  s--;
939  }
940  result <<= s; /* shift when v's highest bits are zero */
941 #endif
942  return result;
943 }
944 
945 
952 #define __CLZ __builtin_clz
953 
954 
955 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
956  (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
957  (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
958  (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
959 
965 __STATIC_FORCEINLINE uint8_t __LDREXB(volatile uint8_t *addr)
966 {
967  uint32_t result;
968 
969 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
970  __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) );
971 #else
972  /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
973  accepted by assembler. So has to use following less efficient pattern.
974  */
975  __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
976 #endif
977  return ((uint8_t) result); /* Add explicit type cast here */
978 }
979 
980 
987 __STATIC_FORCEINLINE uint16_t __LDREXH(volatile uint16_t *addr)
988 {
989  uint32_t result;
990 
991 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
992  __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) );
993 #else
994  /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
995  accepted by assembler. So has to use following less efficient pattern.
996  */
997  __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
998 #endif
999  return ((uint16_t) result); /* Add explicit type cast here */
1000 }
1001 
1002 
1009 __STATIC_FORCEINLINE uint32_t __LDREXW(volatile uint32_t *addr)
1010 {
1011  uint32_t result;
1012 
1013  __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) );
1014  return(result);
1015 }
1016 
1017 
1026 __STATIC_FORCEINLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
1027 {
1028  uint32_t result;
1029 
1030  __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
1031  return(result);
1032 }
1033 
1034 
1043 __STATIC_FORCEINLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
1044 {
1045  uint32_t result;
1046 
1047  __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
1048  return(result);
1049 }
1050 
1051 
1060 __STATIC_FORCEINLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
1061 {
1062  uint32_t result;
1063 
1064  __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
1065  return(result);
1066 }
1067 
1068 
1073 __STATIC_FORCEINLINE void __CLREX(void)
1074 {
1075  __ASM volatile ("clrex" ::: "memory");
1076 }
1077 
1078 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1079  (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1080  (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1081  (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1082 
1083 
1084 #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1085  (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1086  (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) )
1087 
1094 #define __SSAT(ARG1,ARG2) \
1095 __extension__ \
1096 ({ \
1097  int32_t __RES, __ARG1 = (ARG1); \
1098  __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1099  __RES; \
1100  })
1101 
1102 
1110 #define __USAT(ARG1,ARG2) \
1111  __extension__ \
1112 ({ \
1113  uint32_t __RES, __ARG1 = (ARG1); \
1114  __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1115  __RES; \
1116  })
1117 
1118 
1126 __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value)
1127 {
1128  uint32_t result;
1129 
1130  __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
1131  return(result);
1132 }
1133 
1134 
1141 __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr)
1142 {
1143  uint32_t result;
1144 
1145 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1146  __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
1147 #else
1148  /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1149  accepted by assembler. So has to use following less efficient pattern.
1150  */
1151  __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1152 #endif
1153  return ((uint8_t) result); /* Add explicit type cast here */
1154 }
1155 
1156 
1163 __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr)
1164 {
1165  uint32_t result;
1166 
1167 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
1168  __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
1169 #else
1170  /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
1171  accepted by assembler. So has to use following less efficient pattern.
1172  */
1173  __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" );
1174 #endif
1175  return ((uint16_t) result); /* Add explicit type cast here */
1176 }
1177 
1178 
1185 __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr)
1186 {
1187  uint32_t result;
1188 
1189  __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
1190  return(result);
1191 }
1192 
1193 
1200 __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr)
1201 {
1202  __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1203 }
1204 
1205 
1212 __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr)
1213 {
1214  __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1215 }
1216 
1217 
1224 __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
1225 {
1226  __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
1227 }
1228 
1229 #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1230  (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1231  (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1232 
1240 __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
1241 {
1242  if ((sat >= 1U) && (sat <= 32U))
1243  {
1244  const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
1245  const int32_t min = -1 - max ;
1246  if (val > max)
1247  {
1248  return max;
1249  }
1250  else if (val < min)
1251  {
1252  return min;
1253  }
1254  }
1255  return val;
1256 }
1257 
1265 __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
1266 {
1267  if (sat <= 31U)
1268  {
1269  const uint32_t max = ((1U << sat) - 1U);
1270  if (val > (int32_t)max)
1271  {
1272  return max;
1273  }
1274  else if (val < 0)
1275  {
1276  return 0U;
1277  }
1278  }
1279  return (uint32_t)val;
1280 }
1281 
1282 #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
1283  (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \
1284  (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */
1285 
1286 
1287 #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1288  (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
1289 
1295 __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr)
1296 {
1297  uint32_t result;
1298 
1299  __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) );
1300  return ((uint8_t) result);
1301 }
1302 
1303 
1310 __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr)
1311 {
1312  uint32_t result;
1313 
1314  __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) );
1315  return ((uint16_t) result);
1316 }
1317 
1318 
1325 __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr)
1326 {
1327  uint32_t result;
1328 
1329  __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) );
1330  return(result);
1331 }
1332 
1333 
1340 __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr)
1341 {
1342  __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1343 }
1344 
1345 
1352 __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr)
1353 {
1354  __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1355 }
1356 
1357 
1364 __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr)
1365 {
1366  __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
1367 }
1368 
1369 
1376 __STATIC_FORCEINLINE uint8_t __LDAEXB(volatile uint8_t *ptr)
1377 {
1378  uint32_t result;
1379 
1380  __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) );
1381  return ((uint8_t) result);
1382 }
1383 
1384 
1391 __STATIC_FORCEINLINE uint16_t __LDAEXH(volatile uint16_t *ptr)
1392 {
1393  uint32_t result;
1394 
1395  __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) );
1396  return ((uint16_t) result);
1397 }
1398 
1399 
1406 __STATIC_FORCEINLINE uint32_t __LDAEX(volatile uint32_t *ptr)
1407 {
1408  uint32_t result;
1409 
1410  __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) );
1411  return(result);
1412 }
1413 
1414 
1423 __STATIC_FORCEINLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr)
1424 {
1425  uint32_t result;
1426 
1427  __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1428  return(result);
1429 }
1430 
1431 
1440 __STATIC_FORCEINLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr)
1441 {
1442  uint32_t result;
1443 
1444  __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1445  return(result);
1446 }
1447 
1448 
1457 __STATIC_FORCEINLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr)
1458 {
1459  uint32_t result;
1460 
1461  __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) );
1462  return(result);
1463 }
1464 
1465 #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
1466  (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */
1467  /* end of group CMSIS_Core_InstructionInterface */
1469 
1470 
1471 /* ################### Compiler specific Intrinsics ########################### */
1477 #if (__ARM_FEATURE_DSP == 1) /* ToDo ARMCLANG: This should be ARCH >= ARMv7-M + SIMD */
1478 
1479 __STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2)
1480 {
1481  uint32_t result;
1482 
1483  __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1484  return(result);
1485 }
1486 
1487 __STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2)
1488 {
1489  uint32_t result;
1490 
1491  __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1492  return(result);
1493 }
1494 
1495 __STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2)
1496 {
1497  uint32_t result;
1498 
1499  __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1500  return(result);
1501 }
1502 
1503 __STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2)
1504 {
1505  uint32_t result;
1506 
1507  __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1508  return(result);
1509 }
1510 
1511 __STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2)
1512 {
1513  uint32_t result;
1514 
1515  __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1516  return(result);
1517 }
1518 
1519 __STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2)
1520 {
1521  uint32_t result;
1522 
1523  __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1524  return(result);
1525 }
1526 
1527 
1528 __STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2)
1529 {
1530  uint32_t result;
1531 
1532  __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1533  return(result);
1534 }
1535 
1536 __STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2)
1537 {
1538  uint32_t result;
1539 
1540  __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1541  return(result);
1542 }
1543 
1544 __STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
1545 {
1546  uint32_t result;
1547 
1548  __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1549  return(result);
1550 }
1551 
1552 __STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2)
1553 {
1554  uint32_t result;
1555 
1556  __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1557  return(result);
1558 }
1559 
1560 __STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
1561 {
1562  uint32_t result;
1563 
1564  __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1565  return(result);
1566 }
1567 
1568 __STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
1569 {
1570  uint32_t result;
1571 
1572  __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1573  return(result);
1574 }
1575 
1576 
1577 __STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2)
1578 {
1579  uint32_t result;
1580 
1581  __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1582  return(result);
1583 }
1584 
1585 __STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2)
1586 {
1587  uint32_t result;
1588 
1589  __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1590  return(result);
1591 }
1592 
1593 __STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2)
1594 {
1595  uint32_t result;
1596 
1597  __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1598  return(result);
1599 }
1600 
1601 __STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2)
1602 {
1603  uint32_t result;
1604 
1605  __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1606  return(result);
1607 }
1608 
1609 __STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2)
1610 {
1611  uint32_t result;
1612 
1613  __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1614  return(result);
1615 }
1616 
1617 __STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2)
1618 {
1619  uint32_t result;
1620 
1621  __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1622  return(result);
1623 }
1624 
1625 __STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2)
1626 {
1627  uint32_t result;
1628 
1629  __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1630  return(result);
1631 }
1632 
1633 __STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2)
1634 {
1635  uint32_t result;
1636 
1637  __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1638  return(result);
1639 }
1640 
1641 __STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
1642 {
1643  uint32_t result;
1644 
1645  __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1646  return(result);
1647 }
1648 
1649 __STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2)
1650 {
1651  uint32_t result;
1652 
1653  __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1654  return(result);
1655 }
1656 
1657 __STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
1658 {
1659  uint32_t result;
1660 
1661  __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1662  return(result);
1663 }
1664 
1665 __STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
1666 {
1667  uint32_t result;
1668 
1669  __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1670  return(result);
1671 }
1672 
1673 __STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2)
1674 {
1675  uint32_t result;
1676 
1677  __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1678  return(result);
1679 }
1680 
1681 __STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2)
1682 {
1683  uint32_t result;
1684 
1685  __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1686  return(result);
1687 }
1688 
1689 __STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2)
1690 {
1691  uint32_t result;
1692 
1693  __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1694  return(result);
1695 }
1696 
1697 __STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2)
1698 {
1699  uint32_t result;
1700 
1701  __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1702  return(result);
1703 }
1704 
1705 __STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2)
1706 {
1707  uint32_t result;
1708 
1709  __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1710  return(result);
1711 }
1712 
1713 __STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2)
1714 {
1715  uint32_t result;
1716 
1717  __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1718  return(result);
1719 }
1720 
1721 __STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2)
1722 {
1723  uint32_t result;
1724 
1725  __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1726  return(result);
1727 }
1728 
1729 __STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2)
1730 {
1731  uint32_t result;
1732 
1733  __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1734  return(result);
1735 }
1736 
1737 __STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2)
1738 {
1739  uint32_t result;
1740 
1741  __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1742  return(result);
1743 }
1744 
1745 __STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2)
1746 {
1747  uint32_t result;
1748 
1749  __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1750  return(result);
1751 }
1752 
1753 __STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2)
1754 {
1755  uint32_t result;
1756 
1757  __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1758  return(result);
1759 }
1760 
1761 __STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2)
1762 {
1763  uint32_t result;
1764 
1765  __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1766  return(result);
1767 }
1768 
1769 __STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2)
1770 {
1771  uint32_t result;
1772 
1773  __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1774  return(result);
1775 }
1776 
1777 __STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
1778 {
1779  uint32_t result;
1780 
1781  __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1782  return(result);
1783 }
1784 
1785 #define __SSAT16(ARG1,ARG2) \
1786 ({ \
1787  int32_t __RES, __ARG1 = (ARG1); \
1788  __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1789  __RES; \
1790  })
1791 
1792 #define __USAT16(ARG1,ARG2) \
1793 ({ \
1794  uint32_t __RES, __ARG1 = (ARG1); \
1795  __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
1796  __RES; \
1797  })
1798 
1799 __STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1)
1800 {
1801  uint32_t result;
1802 
1803  __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
1804  return(result);
1805 }
1806 
1807 __STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
1808 {
1809  uint32_t result;
1810 
1811  __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1812  return(result);
1813 }
1814 
1815 __STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1)
1816 {
1817  uint32_t result;
1818 
1819  __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
1820  return(result);
1821 }
1822 
1823 __STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
1824 {
1825  uint32_t result;
1826 
1827  __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1828  return(result);
1829 }
1830 
1831 __STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2)
1832 {
1833  uint32_t result;
1834 
1835  __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1836  return(result);
1837 }
1838 
1839 __STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2)
1840 {
1841  uint32_t result;
1842 
1843  __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1844  return(result);
1845 }
1846 
1847 __STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
1848 {
1849  uint32_t result;
1850 
1851  __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1852  return(result);
1853 }
1854 
1855 __STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
1856 {
1857  uint32_t result;
1858 
1859  __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1860  return(result);
1861 }
1862 
1863 __STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
1864 {
1865  union llreg_u{
1866  uint32_t w32[2];
1867  uint64_t w64;
1868  } llr;
1869  llr.w64 = acc;
1870 
1871 #ifndef __ARMEB__ /* Little endian */
1872  __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1873 #else /* Big endian */
1874  __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1875 #endif
1876 
1877  return(llr.w64);
1878 }
1879 
1880 __STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
1881 {
1882  union llreg_u{
1883  uint32_t w32[2];
1884  uint64_t w64;
1885  } llr;
1886  llr.w64 = acc;
1887 
1888 #ifndef __ARMEB__ /* Little endian */
1889  __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1890 #else /* Big endian */
1891  __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1892 #endif
1893 
1894  return(llr.w64);
1895 }
1896 
1897 __STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2)
1898 {
1899  uint32_t result;
1900 
1901  __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1902  return(result);
1903 }
1904 
1905 __STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
1906 {
1907  uint32_t result;
1908 
1909  __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1910  return(result);
1911 }
1912 
1913 __STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
1914 {
1915  uint32_t result;
1916 
1917  __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1918  return(result);
1919 }
1920 
1921 __STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
1922 {
1923  uint32_t result;
1924 
1925  __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
1926  return(result);
1927 }
1928 
1929 __STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
1930 {
1931  union llreg_u{
1932  uint32_t w32[2];
1933  uint64_t w64;
1934  } llr;
1935  llr.w64 = acc;
1936 
1937 #ifndef __ARMEB__ /* Little endian */
1938  __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1939 #else /* Big endian */
1940  __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1941 #endif
1942 
1943  return(llr.w64);
1944 }
1945 
1946 __STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
1947 {
1948  union llreg_u{
1949  uint32_t w32[2];
1950  uint64_t w64;
1951  } llr;
1952  llr.w64 = acc;
1953 
1954 #ifndef __ARMEB__ /* Little endian */
1955  __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
1956 #else /* Big endian */
1957  __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) );
1958 #endif
1959 
1960  return(llr.w64);
1961 }
1962 
1963 __STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2)
1964 {
1965  uint32_t result;
1966 
1967  __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1968  return(result);
1969 }
1970 
1971 __STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2)
1972 {
1973  int32_t result;
1974 
1975  __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1976  return(result);
1977 }
1978 
1979 __STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2)
1980 {
1981  int32_t result;
1982 
1983  __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
1984  return(result);
1985 }
1986 
1987 #if 0
1988 #define __PKHBT(ARG1,ARG2,ARG3) \
1989 ({ \
1990  uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1991  __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
1992  __RES; \
1993  })
1994 
1995 #define __PKHTB(ARG1,ARG2,ARG3) \
1996 ({ \
1997  uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \
1998  if (ARG3 == 0) \
1999  __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \
2000  else \
2001  __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \
2002  __RES; \
2003  })
2004 #endif
2005 
2006 #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
2007  ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
2008 
2009 #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
2010  ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
2011 
2012 __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
2013 {
2014  int32_t result;
2015 
2016  __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
2017  return(result);
2018 }
2019 
2020 #endif /* (__ARM_FEATURE_DSP == 1) */
2021 
2024 #pragma GCC diagnostic pop
2025 
2026 #endif /* __CMSIS_GCC_H */
__STATIC_FORCEINLINE uint32_t __get_CONTROL(void)
Get Control Register.
Definition: cmsis_gcc.h:151
#define __CMSIS_GCC_USE_REG(r)
Definition: cmsis_gcc.h:770
__STATIC_FORCEINLINE uint32_t __get_IPSR(void)
Get IPSR Register.
Definition: cmsis_gcc.h:205
__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat)
Unsigned Saturate.
Definition: cmsis_gcc.h:1265
__STATIC_FORCEINLINE uint32_t __get_PSP(void)
Get Process Stack Pointer.
Definition: cmsis_gcc.h:247
__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)
Set Process Stack Pointer.
Definition: cmsis_gcc.h:277
__STATIC_FORCEINLINE void __DMB(void)
Data Memory Barrier.
Definition: cmsis_gcc.h:829
__PACKED_STRUCT T_UINT16_WRITE
Definition: cmsis_gcc.h:82
#define __PACKED_STRUCT
Definition: cmsis_gcc.h:65
struct __attribute__((packed)) T_UINT32
Definition: cmsis_gcc.h:74
__STATIC_FORCEINLINE uint32_t __get_xPSR(void)
Get xPSR Register.
Definition: cmsis_gcc.h:233
__STATIC_FORCEINLINE int16_t __REVSH(int16_t value)
Reverse byte order (16 bit)
Definition: cmsis_gcc.h:875
__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack)
Set Main Stack Pointer.
Definition: cmsis_gcc.h:331
__PACKED_STRUCT T_UINT32_WRITE
Definition: cmsis_gcc.h:98
__STATIC_FORCEINLINE void __DSB(void)
Data Synchronization Barrier.
Definition: cmsis_gcc.h:818
__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask)
Set Priority Mask.
Definition: cmsis_gcc.h:412
__STATIC_FORCEINLINE uint32_t __REV16(uint32_t value)
Reverse byte order (16 bit)
Definition: cmsis_gcc.h:860
__STATIC_FORCEINLINE void __disable_irq(void)
Disable IRQ Interrupts.
Definition: cmsis_gcc.h:140
#define __STATIC_FORCEINLINE
Definition: cmsis_gcc.h:50
__STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value)
Reverse bit order of value.
Definition: cmsis_gcc.h:922
__STATIC_FORCEINLINE uint32_t __get_APSR(void)
Get APSR Register.
Definition: cmsis_gcc.h:219
__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void)
Get Priority Mask.
Definition: cmsis_gcc.h:382
__STATIC_FORCEINLINE uint32_t __get_MSP(void)
Get Main Stack Pointer.
Definition: cmsis_gcc.h:301
__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
Rotate Right in unsigned value (32 bit)
Definition: cmsis_gcc.h:895
__PACKED_STRUCT T_UINT32_READ
Definition: cmsis_gcc.h:106
#define __ASM
Definition: cmsis_gcc.h:41
#define __CMSIS_GCC_OUT_REG(r)
Definition: cmsis_gcc.h:768
__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control)
Set Control Register.
Definition: cmsis_gcc.h:181
__STATIC_FORCEINLINE void __enable_irq(void)
Enable IRQ Interrupts.
Definition: cmsis_gcc.h:129
__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat)
Signed Saturate.
Definition: cmsis_gcc.h:1240
__PACKED_STRUCT T_UINT16_READ
Definition: cmsis_gcc.h:90
__STATIC_FORCEINLINE void __ISB(void)
Instruction Synchronization Barrier.
Definition: cmsis_gcc.h:807
__STATIC_FORCEINLINE uint32_t __REV(uint32_t value)
Reverse byte order (32 bit)
Definition: cmsis_gcc.h:841